package com.zhht.htzx.model;

import java.io.Serializable;

/**
 * 订单商品项数据模型
 */
public class OrderItem implements Serializable {
    
    private String itemId;        // 商品项ID
    private String productId;     // 商品ID
    private String productName;   // 商品名称
    private String productImage;  // 商品图片
    private String specification; // 商品规格
    private double price;         // 商品单价
    private int quantity;         // 购买数量
    private double totalPrice;    // 小计金额
    
    // 构造函数
    public OrderItem() {}
    
    public OrderItem(String productId, String productName, String productImage, 
                    String specification, double price, int quantity) {
        this.itemId = System.currentTimeMillis() + "_" + productId;
        this.productId = productId;
        this.productName = productName;
        this.productImage = productImage;
        this.specification = specification;
        this.price = price;
        this.quantity = quantity;
        this.totalPrice = price * quantity;
    }
    
    // Getter和Setter方法
    public String getItemId() {
        return itemId;
    }
    
    public void setItemId(String itemId) {
        this.itemId = itemId;
    }
    
    public String getProductId() {
        return productId;
    }
    
    public void setProductId(String productId) {
        this.productId = productId;
    }
    
    public String getProductName() {
        return productName;
    }
    
    public void setProductName(String productName) {
        this.productName = productName;
    }
    
    public String getProductImage() {
        return productImage;
    }
    
    public void setProductImage(String productImage) {
        this.productImage = productImage;
    }
    
    public String getSpecification() {
        return specification;
    }
    
    public void setSpecification(String specification) {
        this.specification = specification;
    }
    
    public double getPrice() {
        return price;
    }
    
    public void setPrice(double price) {
        this.price = price;
        this.totalPrice = price * quantity;
    }
    
    public int getQuantity() {
        return quantity;
    }
    
    public void setQuantity(int quantity) {
        this.quantity = quantity;
        this.totalPrice = price * quantity;
    }
    
    public double getTotalPrice() {
        return totalPrice;
    }
    
    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }
    
    // 获取规格显示文本
    public String getSpecificationDisplayText() {
        if (specification == null || specification.isEmpty()) {
            return "默认规格";
        }
        return specification;
    }
    
    // 获取价格显示文本
    public String getPriceDisplayText() {
        return String.format("¥%.2f", price);
    }
    
    // 获取小计显示文本
    public String getTotalPriceDisplayText() {
        return String.format("¥%.2f", totalPrice);
    }
} 